-
Notifications
You must be signed in to change notification settings - Fork 1.1k
new format for "package name already defined" error (+tests) #3437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new format for "package name already defined" error (+tests) #3437
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
@smarter scalac does not emit an error here. Is the difference intended? |
7ea27f1
to
95fcac1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! Please rebase your PR
implicit val ctx: Context = ictx | ||
|
||
assertMessageCount(1, messages) | ||
assert(messages.head.isInstanceOf[PackageNameAlreadyDefined]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer:
val PackageNameAlreadyDefined(pkg) = messages.head
assertEquals(pkg.show, "object bar")
|
||
override def msg: String = hl"${pkg} is already defined, cannot be a package" | ||
override def kind: String = "Syntax" | ||
override def explanation: String = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The override
keyword as well as the type ascription are a bit verbose. I would remove them
override def msg: String = hl"${pkg} is already defined, cannot be a package" | ||
override def kind: String = "Syntax" | ||
override def explanation: String = | ||
"An object cannot have the same name as an existing package. Rename ${pkg} or the package with the same name." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use hl
interpolator for syntax highlighting:
hl"An ${"object"} cannot have the same name as an existing ${"package"}. Rename either one of them."
|
||
case class PackageNameAlreadyDefined(pkg: Symbol)(implicit ctx: Context) extends Message(PackageNameAlreadyDefinedID) { | ||
|
||
override def msg: String = hl"${pkg} is already defined, cannot be a package" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can syntax highlight package
in this sentence:
hl"${pkg} is already defined, cannot be a ${"package"}"
95fcac1
to
8d8baba
Compare
Thanks for your review ! I rebased my branch and applied the modifications. |
8d8baba
to
a74feb6
Compare
PR from Scala.io 2017 FLOSS spree in Lyon.
For #1589 :
This PR creates a new format of error messages for
Typer.scala:1519
. The newMessage
class isPackageNameAlreadyDefined
.